﻿/*
 * Reports the zero-based index of the last occurrence of the specified string in this string.
 */
create function [String].[LastIndexOf] ( @p_String nvarchar(max), @p_Term nvarchar(max) )
returns int as
begin

  return Len( @p_String ) - PatIndex( Reverse( @p_String ), @p_Term );

end